import { defineConfig } from 'eslint/config'
import eslint from '@eslint/js'
import tselint from 'typescript-eslint'
import eslintPluginPrettier from 'eslint-plugin-prettier'
import eslintPluginVue from 'eslint-plugin-vue'
import globals from 'globals'
import eslintConfigPrettier from 'eslint-config-prettier/flat'

const ignores = ["**/node_modules/**", "**/dist/**", ".*", "scripts/**", "**/*.d.ts"]

export default defineConfig(
    {
        ignores,
        extends: [eslint.configs.recommended, ...tselint.configs.recommended, eslintConfigPrettier],
        plugins: {
            'prettier': eslintPluginPrettier,
        },
        languageOptions: {
            ecmaVersion: 'latest',
            sourceType: 'module',
            parser: tselint.parser,
        },
        rules: {
            'no-var': 'error',
        },
    },
    {
        ignores,
        files: ["apps/frontend/**/*.{ts,tsx,js,jsx,vue}", "packages/components/**/*.{ts,tsx,js,jsx,vue}"],
        extends: [...eslintPluginVue.configs["flat/recommended"], eslintConfigPrettier],
        languageOptions: {
            globals: {
                ...globals.browser
            }
        }
    },
    {
        ignores,
        files: ["apps/backend/**/*.{ts,js}"],
        languageOptions: {
            globals: {
                ...globals.node
            }
        }
    }
)